package com.peace.hospital.opdept.mapper.outpatientdept;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peace.hospital.entity.common.People;
import com.peace.hospital.entity.outpatientdept.Chargingitems;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 处方表 Mapper 接口
 * </p>
 *
 * @author 谢晓峰
 * @since 2019-11-11
 */
@Mapper
public interface ChargingitemsMapper extends BaseMapper<Chargingitems> {

    /**添加处方信息*/
    @Insert("insert into outpatientDepartment.chargingitems(staid,parchargeitemid,pid,chaname,chastarttime,charemarks,chadbsource) values(#{staid},#{parchargeitemid},#{pid},#{chaname},now(),'挂号费','outpatientDepartment')")
    int addChargingitems(Chargingitems chargingitems);

    /**根据病人id查询挂号检查费用*/
    @Select("select particulars.parprice from outpatientDepartment.chargingitems " +
            "inner join particulars on chargingitems.parchargeitemid=particulars.parchargeitemid where pid=#{pid}")
    List<Double> selectChargpriceByPid(Integer pid);

    /**根据病人id查询挂号检查信息*/
//    @Select("select chargingitems*,particulars.parprice from outpatientDepartment.chargingitems " +
//            "inner join outpatientDepartment.particulars on chargingitems.parchargeitemid=particulars.parchargeitemid " +
//            "where pid=#{pid}")
    @Select("select chargingitems.*,particulars.parprice from outpatientDepartment.chargingitems " +
            "inner join outpatientDepartment.particulars on chargingitems.parchargeitemid=particulars.parchargeitemid " +
            "where pid=#{pid}")
    @Results(
            @Result(column = "parprice",property = "unitPrice")
    )
    List<Chargingitems> selectChargingitemsByPid(Integer pid);
}
